package com.bj58.migrate;

import com.bj58.ses.agent.SESAgent;
import com.bj58.sfft.cmc.contract.ICategoryService;
import com.bj58.sfft.cmc.contract.IDispCategoryService;
import com.bj58.sfft.cmc.contract.IDispLocalService;
import com.bj58.sfft.cmc.contract.IDispLocalService2;
import com.bj58.sfft.cmc.contract.ILocalService;
import com.bj58.sfft.imc.contract.IInfoService;
import com.bj58.spat.scf.client.proxy.builder.ProxyFactory;

public class ScfProxy{

	public static < T >T getSCFInterFace( Class< T > interFace, String StrServiceUrl ){

		try{
			return ( T )ProxyFactory.create( interFace, StrServiceUrl );
		}
		catch( Exception e ){
			e.printStackTrace();
		}
		return null;
	}

	public final static ICategoryService cmc_Category(){

		return getSCFInterFace( ICategoryService.class, "tcp://cmc/CategoryService" );
	}

	/** CMC表现分类服务实例化 **/
	public final static IDispCategoryService cmc_DispCategory(){

		return getSCFInterFace( IDispCategoryService.class, "tcp://cmc/DispCategoryService" );
	}

	public final static ILocalService cmc_Local(){

		return getSCFInterFace( ILocalService.class, "tcp://cmc/LocalService" );
	}

	public final static IInfoService imc_InfoProviderWithIndex(){

		return getSCFInterFace( IInfoService.class, "tcp://imc/InfoProviderWithIndex" );
	}

	public final static IDispLocalService2 cmc_DispLocal2(){

		return getSCFInterFace( IDispLocalService2.class, "tcp://cmc/DispLocalService2" );
	}

	public final static IDispLocalService cmc_DispLocal(){

		return getSCFInterFace( IDispLocalService.class, "tcp://cmc/DispLocalService" );
	}

	private static SESAgent ses_agent = null;

	public final static SESAgent ses_SESAgent(){

		if( ses_agent == null ){
			synchronized( ScfProxy.class ){
				if( ses_agent == null ) ses_agent = new SESAgent();
			}
		}
		return ses_agent;
	}
}
